package com.bflow.api.constant;

public interface BflowConstant {

    //活动分割符
    String ACT_SPLIT = ",";
    String UNDERLINE = "_";

    //流程定义 KEY 模板前缀
    String PROCESS_KEY_TPL_PREFIX = "tpl_";


    String PARAM_NAME_NEXT_ASSIGNEE = "NEXT_ASSIGNEE";

    //默认活动
    enum DefActKey{
        DEF_USER_AUDIT("def_user_audit", "用户审批"),
        ;

        DefActKey(String code,String title){
            this.code=code;
            this.title=title;
        }
        private String code;
        private String title;
        public String getCode() {
            return this.code;
        }
        public String getTitle() {
            return this.title;
        }
        public boolean eq(String code) {
            if (code == null || code.length() == 0)
                return false;
            return getCode().equals(code);
        }
    }

    /**
     * 活动分派 类型
     */
    enum ActAssignTypes{
        ASSIGN_USER_ID("ASSIGN_USER_ID", "手动分派用户"),
        ASSIGN_ROLE_KEY("ASSIGN_ROLE_KEY", "手动分派角色"),
        USER_ID("USER_ID", "指定用户"),
        ROLE_KEY("ROLE_KEY", "指定角色"),
        TRANSFER_USER_ID("TRANSFER_USER_ID", "手动转交用户"),
        ;

        ActAssignTypes(String code,String title){
            this.code=code;
            this.title=title;
        }
        private String code;
        private String title;
        public String getCode() {
            return this.code;
        }
        public String getTitle() {
            return this.title;
        }
        public boolean eq(String code) {
            if (code == null || code.length() == 0)
                return false;
            return getCode().equals(code);
        }

        public static ActAssignTypes get(String code) {
            if (code == null || code.length() == 0)
                return null;
            ActAssignTypes[] types = values();
            for (ActAssignTypes type : types) {
                if (type.getCode().equals(code)) {
                    return type;
                }
            }
            return null;
        }
    }

    /**
     * 流程实例表 流程状态
     * finish=已完成；run=执行中; cancel=撤销'
     */
    enum FlowRunInstanceStatus{
        FINISH("finish","完成"),
        RUN("run","执行中"),
        CANCLEL("cancel","取消");

        FlowRunInstanceStatus(String code, String title){
            this.code=code;
            this.title=title;
        }

        private String code;
        private String title;

        public String getCode() {
            return code;
        }
        public String getTitle() {
            return this.title;
        }

        public static FlowRunInstanceStatus get(String code) {
            if (code == null || code.length() == 0)
                return null;
            FlowRunInstanceStatus[] statuses = values();
            for (FlowRunInstanceStatus status : statuses) {
                if (status.getCode().equals(code)) {
                    return status;
                }
            }
            return null;
        }

        public boolean eq(String code) {
            if (code == null || code.length() == 0)
                return false;
            return getCode().equals(code);
        }
    }

    enum CommStatus{
        N("0","无效"),
        Y("1","有效");

        CommStatus(String code,String title){
            this.code=code;
            this.title=title;
        }

        private String code;
        private String title;

        public String getCode() {
            return this.code;
        }
        public String getTitle() {
            return this.title;
        }

        public int getIntCode(){
            return Integer.parseInt(this.code);
        }
    }

    /**
     * 任务状态： 0-待处理；1-已处理；
     */
    enum RunTaskStatus{
        WAITING_DEAL("0","待处理"),
        FINISH_DEAL("1","已处理");

        RunTaskStatus(String code,String title){
            this.code=code;
            this.title=title;
        }

        private String code;
        private String title;

        public String getCode() {
            return this.code;
        }
        public String getTitle() {
            return this.title;
        }
    }

    /**
     * 初始版本=1
     */
    enum CommVersion{
        INITIAL(1, "初始版本"),
        ;

        CommVersion(Integer code,String title){
            this.code=code;
            this.title=title;
        }

        private Integer code;
        private String title;

        public Integer getCode() {
            return code;
        }

        public String getTitle() {
            return this.title;
        }
    }

    /**
     * 默认流程活动路由 条件说明
     *      DEF_PASS=审批通过； DEF_NOPASS=审批不通过
     */
    enum CommDefineActRouteCondDesc {
        DEF_PASS("审批通过","def_pass"),
        DEF_NOPASS("审批不通过","def_nopass"),
        ;

        CommDefineActRouteCondDesc(String title, String code) {
            this.code = code;
            this.title = title;
        }

        private String title;
        private String code;

        public String getCode() {
            return code;
        }

        public String getTitle() {
            return title;
        }

        /**
         * 获取
         * @param code
         * @return
         */
        public static CommDefineActRouteCondDesc get(String code) {
            if (code == null || code.length() == 0)
                return null;
            CommDefineActRouteCondDesc[] statuses = values();
            for (CommDefineActRouteCondDesc status : statuses) {
                if (status.getCode().equals(code)) {
                    return status;
                }
            }
            return null;
        }

        public boolean eq(String code) {
            if (code == null || code.length() == 0)
                return false;
            return getCode().equals(code);
        }
    }

    /**
     * 流程类型
     */
    enum ProcessType{
        DEF("def","默认"),
        SET("set","自定义");

        ProcessType(String code,String title){
            this.code=code;
            this.title=title;
        }
        private String code;
        private String title;

        public String getCode() {
            return this.code;
        }
        public String getTitle() {
            return this.title;
        }

        public boolean eq(String code) {
            if (code == null || code.length() == 0)
                return false;
            return getCode().equals(code);
        }
    }

    /**
     * 流程业务KEY类型
     *      leaveApply=请假申请；
     */
    enum ProcessBusiKeyType {
        LEAVEAPPLY("leaveApply", "请假申请"),
        ;

        private ProcessBusiKeyType(String code, String title) {
            this.code = code;
            this.title = title;
        }

        private String code;
        private String title;


        public String getCode() {
            return code;
        }

        public String getTitle() {
            return this.title;
        }

        /**
         * 获取
         * @param code
         * @return
         */
        public static ProcessBusiKeyType get(String code) {
            if (code == null || code.length() == 0)
                return null;
            ProcessBusiKeyType[] statuses = values();
            for (ProcessBusiKeyType status : statuses) {
                if (status.getCode().equals(code)) {
                    return status;
                }
            }
            return null;
        }

        /**
         * 是否相等
         * @param code
         * @return
         */
        public boolean eq(String code) {
            if (code == null || code.length() == 0)
                return false;
            return getCode().equals(code);
        }
    }

    /**
     * 流程实例表_最终结论
     *     pass=通过；noPass=未通过;
     */
    enum RunInstance_FinalConclusion{
        PASS("pass","通过"),
        NOPASS("noPass","未通过"),
        ;

        RunInstance_FinalConclusion(String code, String title){
            this.code=code;
            this.title=title;
        }

        private String code;
        private String title;

        public String getCode() {
            return code;
        }
        public String getTitle() {
            return this.title;
        }

        public static RunInstance_FinalConclusion get(String code) {
            if (code == null || code.length() == 0)
                return null;
            RunInstance_FinalConclusion[] statuses = values();
            for (RunInstance_FinalConclusion status : statuses) {
                if (status.getCode().equals(code)) {
                    return status;
                }
            }
            return null;
        }

        public boolean eq(String code) {
            if (code == null || code.length() == 0)
                return false;
            return getCode().equals(code);
        }
    }

    /**
     * 流程定义表_抄送间隔类型
     *    start=开始、end=结束、endPass=通过结束、endNoPass=不通过结束、ever=永远
     */
    enum DefineProcess_CopyToIntervalType{
        START("start","开始"),
        END("end","结束"),
        ENDPASS("endPass","通过结束"),
        ENDNOPASS("endNoPass","不通过结束"),
        EVER("ever","永远"),
        ;

        DefineProcess_CopyToIntervalType(String code, String title){
            this.code=code;
            this.title=title;
        }

        private String code;
        private String title;

        public String getCode() {
            return code;
        }
        public String getTitle() {
            return this.title;
        }

        public static DefineProcess_CopyToIntervalType get(String code) {
            if (code == null || code.length() == 0)
                return null;
            DefineProcess_CopyToIntervalType[] statuses = values();
            for (DefineProcess_CopyToIntervalType status : statuses) {
                if (status.getCode().equals(code)) {
                    return status;
                }
            }
            return null;
        }

        public boolean eq(String code) {
            if (code == null || code.length() == 0)
                return false;
            return getCode().equals(code);
        }
    }

}
